home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / systrayc / csstray.exe / _SETUP.1 / frmEx3.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-08-19  |  4.5 KB  |  119 lines

  1. VERSION 5.00
  2. Object = "{0DE92B77-C272-11D1-82B4-E5132F8CF155}#3.1#0"; "CSSTRAY.OCX"
  3. Begin VB.Form frmEx3 
  4.    Caption         =   "SysTray Example #3"
  5.    ClientHeight    =   2025
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   5265
  9.    Icon            =   "frmEx3.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    ScaleHeight     =   2025
  13.    ScaleWidth      =   5265
  14.    ShowInTaskbar   =   0   'False
  15.    StartUpPosition =   2  'CenterScreen
  16.    Begin VB.CommandButton cmdClose 
  17.       Caption         =   "&Close"
  18.       Height          =   375
  19.       Left            =   4080
  20.       TabIndex        =   0
  21.       Top             =   1560
  22.       Width           =   1095
  23.    End
  24.    Begin csSysTrayCtl.csSysTray csSysTray1 
  25.       Left            =   2760
  26.       Top             =   1320
  27.       _ExtentX        =   2064
  28.       _ExtentY        =   1111
  29.       TrayIcon        =   "frmEx3.frx":0442
  30.       TrayTip         =   "Click me to see the window again!"
  31.       TrayVisible     =   0   'False
  32.    End
  33.    Begin VB.Label Label3 
  34.       Caption         =   "This example application shows just how easy it is to use the SysTray control in your own application."
  35.       BeginProperty Font 
  36.          Name            =   "MS Sans Serif"
  37.          Size            =   8.25
  38.          Charset         =   0
  39.          Weight          =   700
  40.          Underline       =   0   'False
  41.          Italic          =   0   'False
  42.          Strikethrough   =   0   'False
  43.       EndProperty
  44.       Height          =   495
  45.       Left            =   120
  46.       TabIndex        =   2
  47.       Top             =   120
  48.       Width           =   5055
  49.    End
  50.    Begin VB.Label Label4 
  51.       Caption         =   $"frmEx3.frx":0894
  52.       BeginProperty Font 
  53.          Name            =   "MS Sans Serif"
  54.          Size            =   8.25
  55.          Charset         =   0
  56.          Weight          =   700
  57.          Underline       =   0   'False
  58.          Italic          =   0   'False
  59.          Strikethrough   =   0   'False
  60.       EndProperty
  61.       Height          =   780
  62.       Left            =   120
  63.       TabIndex        =   1
  64.       Top             =   600
  65.       Width           =   5055
  66.    End
  67. Attribute VB_Name = "frmEx3"
  68. Attribute VB_GlobalNameSpace = False
  69. Attribute VB_Creatable = False
  70. Attribute VB_PredeclaredId = True
  71. Attribute VB_Exposed = False
  72. Option Explicit
  73. 'Example program for SysTray Control
  74. '(C) Copyright 1998 Charon Software, All Rights Reserved
  75. 'You may use or modify this code in any way you see fit.
  76. 'Charon Software takes no responsibility for what you may
  77. 'do with this or any modification of this code.
  78. 'This example shows how easy it is to change the default
  79. 'minimize behavior to minimize to the system tray instead!
  80. Private Sub cmdClose_Click()
  81.     'pretty simple; just unload our form.  The system tray
  82.     'icons will go away automatically!
  83.     Unload Me
  84. End Sub
  85. Private Sub csSysTray1_AfterMinimize(hWnd As Long)
  86.     'the AfterMinimize event occurs after the user clicked
  87.     'the minimize button on the window.  When we "minimize"
  88.     'to the system tray, we actually just hide the window.
  89.     'we know we're "zoomed" to the tray, so just show the icon.
  90.     csSysTray1.TrayShow
  91. End Sub
  92. 'When the user clicks on the icon, we want to zoom the window
  93. 'back to its regular spot.  However, we don't want the system
  94. 'tray icon to disappear until the window is fully restored.
  95. 'If the user were to double-click really fast, they could
  96. 'launch the zoom animation twice!  So, we create a static
  97. 'variable here to exit the event sub up front if we are
  98. 'processing inside of it.
  99. '**************
  100. Private Sub csSysTray1_Click()
  101. Static sProcessing As Boolean
  102.     If sProcessing = True Then Exit Sub 'if we're still zooming,
  103.                                         'don't do it again!
  104.     sProcessing = True 'okay, we're starting to zoom the window.
  105.     'if the user clicks on the icon, zoom our form from the
  106.     'tray and remove the icon!
  107.     csSysTray1.ZoomFromTray Me.hWnd
  108.     csSysTray1.TrayHide
  109.     sProcessing = False 'we're done processing now :)
  110. End Sub
  111. Private Sub Form_Load()
  112.     'the following function will instruct the SysTray control
  113.     'to "watch" our window.  If the user clicks on the minimize
  114.     'button, the window will be zoomed to the system tray and
  115.     'hidden instead.  We can stop watching the window with the
  116.     'RemoveMinimizeWatch method.
  117.     csSysTray1.AddMinimizeWatch Me.hWnd
  118. End Sub
  119.